home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_100
/
129_01
/
210roomb.c
< prev
next >
Wrap
Text File
|
1985-03-09
|
20KB
|
705 lines
/************************************************************************/
/* roomb.c */
/* room code for Citadel bulletin board system */
/************************************************************************/
/************************************************************************/
/* History */
/* */
/* 84Dec28 HAW indexRooms modified to list deleted rooms. */
/* 84Dec20 JLS renameRoom changed aides can decide to cause amnesia. */
/* 84Dec20 JLS & HAW "vp" union eliminated from the system. */
/* 84Jun28 JLS Enhancement: Creator of a room is listed in Aide>. */
/* 84Jun23 HAW & JLS Local unused variables are zapped. */
/* 84Jun10 JLS Room cannot have a name of length 0. */
/* 84May07 JLS & HAW Fix bug in makeRoom to ensure correct g. # inc.ed. */
/* 84Apr04 HAW Start upgrade to BDS 1.50a. */
/* 83Feb26 CrT bug in makeRoom when out of rooms fixed. */
/* 83Feb26 CrT matchString made caseless, normalizeString() */
/* 83Feb26 CrT "]" directory prompt, user name before prompts */
/* 82Dec06 CrT 2.00 release. */
/* 82Nov02 CrT Cleanup prior to V1.2 mods. */
/* 82Nov01 CrT Proofread for CUG distribution. */
/* 82Mar27 dvm conversion to v. 1.4 begun */
/* 82Mar25 dvm conversion for TRS-80/Omikron test started */
/* 81Dec21 CrT Log file... */
/* 81Dec20 CrT Messages... */
/* 81Dec19 CrT Rooms seem to be working... */
/* 81Dec12 CrT Started. */
/************************************************************************/
#include <210ctdl.h>
/************************************************************************/
/* Contents */
/* */
/* editText() handles the end-of-message-entry menu */
/* findRoom() find a free room */
/* getNumber() prompt user for a number, limited range */
/* getRoom() load given room into RAM */
/* getString() read a string in from user */
/* getText() reads a message in from user */
/* getYesNo() prompts for a yes/no response */
/* givePrompt() gives usual "THISROOM>" prompt */
/* indexRooms() build RAM index to ctdlroom.sys */
/* makeRoom() make new room via user dialogue */
/* matchString() search for given string */
/* noteRoom() enter room into RAM index */
/* putRoom() store room to given disk slot */
/* renameRoom() sysop special to rename rooms */
/* replaceString() string-substitute for message entry */
/* zapRoomFile() erase & re-initialize ctdlroom.sys */
/************************************************************************/
/************************************************************************/
/* editText() handles the end-of-message-entry menu. */
/* return TRUE to save message to disk, */
/* FALSE to abort message, and */
/* ERROR if user decides to continue */
/************************************************************************/
int editText(buf, lim)
char *buf;
int lim;
{
char iChar(), toUpper()/*, buff[BUFSIZ]*/;
/*
int count;
count = 25; */
do {
outFlag = OUTOK;
mPrintf("\n entry cmd: ");
switch (toUpper(iChar())) {
case 'A':
mPrintf("bort\n ");
if (getYesNo(" confirm")) return FALSE;
break;
case 'C':
mPrintf("ontinue\n ");
return ERROR;
case 'P':
mPrintf("rint formatted\n ");
doCR();
mPrintf( " ");
printDate();
if (loggedIn) mPrintf(" from %s", msgBuf.mbauth);
doCR();
mFormat(buf);
break;
case 'R':
mPrintf("eplace string\n ");
replaceString(buf, lim);
break;
case 'S':
mPrintf("ave buffer\n ");
return TRUE;
default:
tutorial("edit.mnu");
/*count--;*/
break;
}
} while ((haveCarrier || onConsole)/* && count*/);
/*if (count == 0) {
fcreat("blasted", buff);
fprintf(buff, "%s\nhC=%d, oC=%d, jLC=%d, Ooops=%d\nnC=%d, wIO=%d\032",
logBuf.lbname,
haveCarrier, onConsole, justLostCarrier, Ooops, newCarrier,
whichIO);
fclose(buff);
onConsole = FALSE;
haveCarrier = interpret(pCarrDetect);
justLostCarrier = !haveCarrier;
}*/
return FALSE;
}
/************************************************************************/
/* findRoom() returns # of free room if possible, else ERROR */
/************************************************************************/
int findRoom()
{
int roomRover;
for (roomRover=0; roomRover<MAXROOMS; roomRover++) {
if (!(roomTab[roomRover].rtflags & INUSE)) return roomRover;
}
return ERROR;
}
/************************************************************************/
/* getNumber() prompts for a number in (bottom, top) range. */
/************************************************************************/
int getNumber(prompt, bottom, top)
char *prompt;
unsigned bottom;
unsigned top;
{
unsigned try;
char numstring[NAMESIZE];
do {
outFlag = OUTOK;
getString(prompt, numstring, NAMESIZE);
try = atoi(numstring);
if (try < bottom) mPrintf("Sorry, must be at least %d\n", bottom);
if (try > top ) mPrintf("Sorry, must be no more than %d\n", top);
} while ((try < bottom || try > top)
&& (haveCarrier || onConsole)
);
return try;
}
/************************************************************************/
/* getRoom() */
/************************************************************************/
getRoom(rm)
int rm;
{
int read();
unsigned val;
/* load room #rm into memory starting at buf */
thisRoom = rm;
seek(roomfl, rm*SECSPERROOM, 0);
if ((val = read(roomfl, &roomBuf, SECSPERROOM)) >= 1000) {
printf(" ?getRoom(): read failed, val=%d\n", val);
}
crypte(&roomBuf, (SECSPERROOM * SECTSIZE), rm);
}
/************************************************************************/
/* getString() gets a string from the user. */
/************************************************************************/
getString(prompt, buf, lim)
char *prompt;
char *buf;
int lim; /* max # chars to read */
{
char iChar();
char c;
int i;
outFlag = OUTOK;
if(strLen(prompt) > 0) {
doCR();
mPrintf("Enter %s\n : ", prompt, lim);
}
i = 0;
while (
c = iChar(),
c != NEWLINE
&& i < lim
&& (haveCarrier || onConsole)
) {
outFlag = OUTOK;
/* handle delete chars: */
if (c == BACKSPACE) {
oChar(' ');
oChar(BACKSPACE);
if (i > 0) i--;
else {
oChar(' ');
oChar(BELL);
}
} else buf[i++] = c;
if (i >= lim) {
oChar(BELL);
oChar(BACKSPACE); i--;
}
/* kludge to return immediately on single '?': */
if (*buf == '?') {
doCR();
break;
}
}
buf[i] = '\0';
}
/************************************************************************/
/* getText() reads a message from the user */
/* Returns TRUE if user decides to save it, else FALSE */
/************************************************************************/
char getText(prompt, buf, lim, recipient)
char *prompt;
char *buf;
char *recipient; /* Meaningful iff thisRoom == MAILROOM */
int lim; /* max # chars to read */
{
char iChar(), visible();
char c, sysopAbort;
int i, toReturn;
outFlag = OUTOK;
if (!expert) tutorial("entry.blb");
outFlag = OUTOK;
if (!expert) mPrintf( "Enter %s (end with empty line)", prompt);
outFlag = OUTOK;
doCR();
mPrintf( " ");
printDate();
if (loggedIn) mPrintf("from %s", msgBuf.mbauth);
if (thisRoom == MAILROOM) mPrintf(" to %s", recipient);
doCR();
lim--;
i = 0;
toReturn = TRUE;
sysopAbort = FALSE;
do {
if (whichIO == MODEM) {
fastIn(toReturn == ERROR);
if (whichIO != MODEM) sysopAbort = TRUE;
} else {
/* this code would handle the modem as well... */
/* fastIn() is a later addition to handle people */
/* who like to upload fast without handshaking */
while (
!( (c=iChar()) == NEWLINE && buf[i-1] == NEWLINE )
&& i < lim
&& (haveCarrier ||